<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/WEB-INF/layout/t.xhtml">
	<ui:define name="title">
		<h:outputText value="Gestione Configurazione" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="admin" />
	</ui:define>

	<ui:define name="content">

		<center>
			<h:form>
				<p:panel header="Gestione Configurazione">

					<h:panelGrid columns="2" style="width: 95%">

						<h:outputLabel value="Server smtp(*):" for="smtp" />
						<h:inputText required="true" id="smtp"
							value="#{emailConfigurationController.element.smtp}"
							style="width: 100%;" />

						<h:outputLabel value="Server port(*):" for="port" />
						<h:inputText required="true" id="port"
							value="#{emailConfigurationController.element.serverPort}"
							style="width: 100%;" />

						<h:outputLabel value="username:" for="username" />
						<h:inputText id="username"
							value="#{emailConfigurationController.element.username}"
							style="width: 100%;" />

						<h:outputLabel value="password:" for="password" />
						<h:inputSecret id="password"
							value="#{emailConfigurationController.element.password}"
							style="width: 100%;" />

						<h:outputLabel value="Forward Mail:" for="forwardMail" />
						<h:inputText id="forwardMail"
							value="#{emailConfigurationController.element.forwardMail}"
							style="width: 100%;" />

						<h:outputLabel value="con autenticazione?:" for="withAuth" />
						<h:selectBooleanCheckbox title="withAuth" id="withAuth"
							value="#{emailConfigurationController.element.withAuth}">
						</h:selectBooleanCheckbox>

						<h:outputLabel value="di tipo ssl?:" for="withSsl" />
						<h:selectBooleanCheckbox title="withSsl" id="withSsl"
							value="#{emailConfigurationController.element.withSsl}">
						</h:selectBooleanCheckbox>

						<h:outputLabel value="debug attivo?:" for="withDebug" />
						<h:selectBooleanCheckbox title="withDebug" id="withDebug"
							value="#{emailConfigurationController.element.withDebug}">
						</h:selectBooleanCheckbox>

					</h:panelGrid>
					<br />

				</p:panel>
				<br />
				<br />

				<h:panelGrid columns="4">

					<h:commandButton action="#{emailConfigurationController.update}"
						value="Salva le modifiche" />

					<h:commandButton id="reset"
						action="#{emailConfigurationController.reset}" value="Annulla"
						immediate="true" />

				</h:panelGrid>
			</h:form>
			<br /> <br />
			<h:form>
				<p:panel
					header="Prova Configurazione: #{emailConfigurationController.element.smtp}"
					id="testEmailPanel">

					<h:panelGrid columns="3">
						<h:inputText required="true" id="smtp"
							value="#{emailConfigurationController.emailTest}"
							style="width: 100%;" />

						<h:commandButton value="Invia email di test"
							action="#{emailConfigurationController.test}" />

						<h:commandButton id="reset"
							action="#{emailConfigurationController.setResultTest('')}"
							value="Annulla" immediate="true" />

					</h:panelGrid>
					<br />
					<br />
					<h:outputText id="resultTest"
						value="risultato del test: #{emailConfigurationController.resultTest}"
						rendered="#{not empty emailConfigurationController.resultTest}" />
				</p:panel>
			</h:form>
		</center>


	</ui:define>
</ui:composition>